package com.softer.wxzj.controller;


import com.github.pagehelper.PageInfo;
import com.softer.wxzj.common.aop.annotation.LogRecord;
import com.softer.wxzj.common.aop.enums.LogOperationType;
import com.softer.wxzj.common.aop.enums.LogOperationUnit;
import com.softer.wxzj.common.entity.CommonResult;
import com.softer.wxzj.common.entity.Page;
import com.softer.wxzj.entity.DicType;
import com.softer.wxzj.service.DicTypeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * DictypeController class
 * @author wxr
 * @date 2019/4/10
 */
@RestController
@RequestMapping("/dictype")
@Slf4j
public class DicTypeController {
    @Autowired
    DicTypeService dictypeService;

    /**
     * 字典类型增加
     * @param dictype
     * @return
     */
    @RequestMapping("/add")
    @LogRecord(description = "字典类型增加",operationUnit = LogOperationUnit.DIC_TYPE,operationType = LogOperationType.INSERT)
    public CommonResult add(DicType dictype) {
        return dictypeService.insert(dictype);
    }

    /**
     * 字典类型修改
     * @param f
     * @return
     */
    @RequestMapping("/update")
    @LogRecord(description = "字典类型修改",operationUnit = LogOperationUnit.DIC_TYPE,operationType = LogOperationType.UPDATE)
    public CommonResult update(DicType f) {
        return dictypeService.update(f);
    }

    /**
     * 字典类型删除
     * @param id
     * @return
     */
    @RequestMapping("/delete")
    @LogRecord(description = "字典类型删除",operationUnit = LogOperationUnit.DIC_TYPE,operationType = LogOperationType.DELETE)
    public CommonResult delete(String id) {
        return dictypeService.delete(id);
    }

    /**
     * 字典类型查看
     * @param page
     * @param f
     * @return
     */
    @RequestMapping("/getList")
    @LogRecord(description = "字典类型查看",operationUnit = LogOperationUnit.DIC_TYPE,operationType = LogOperationType.SELECT)
    public PageInfo<DicType> getList(Page page, DicType f) {
        return dictypeService.getList(page,f);
    }

    /**
     * 字典类型查询修改数据
     * @param id
     * @return
     */
    @RequestMapping("/getInfo")
    @LogRecord(description = "字典类型查询修改数据",operationUnit = LogOperationUnit.DIC_TYPE,operationType = LogOperationType.SELECT)
    public DicType getInfo(String id){
        return dictypeService.getInfo(id);
    }
    @RequestMapping("/fuzzySearch")
    @LogRecord(description = "模糊查询查询角色",operationUnit = LogOperationUnit.DIC_TYPE,operationType = LogOperationType.SELECT)
    public PageInfo<DicType> fuzzySearch(Page page,String fuzzy) {
        return dictypeService.fuzzySearch(page,fuzzy);
    }

}
